{template 'common/header'}
<link rel="stylesheet" type="text/css" href="../addons/{php echo $_GPC['m']}/resource/css/style.css" />
<link rel="stylesheet" type="text/css" href="../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.css" />
<link rel="stylesheet" type="text/css" href="../addons/{php echo $_GPC['m']}/resource/bootstrap-select/bootstrap-select.min.css" />
<style>
    .content_type1,.content_type2{display: none;}
</style>
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">
            名师>编辑
        </h3>
    </div>
    <div class="panel-body">
        <form id="sign-form" class="form-horizontal" role="form" method="post" action="{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'],'op'=>'savemodel','version_id'=>$_GPC['version_id'])}" name="submit" style="padding: 20px 0;">
            <div class="form-group">
                <label for="name" class="col-sm-2 control-label">名字</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control"  name="name" id="name" value="{$list['name']}">
                    <input type="hidden" name="id" value="{$list['id']}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">分类</label>
                <div class="col-sm-8">
                    <select class="selectpicker show-tick form-control bs-select-hidden" data-live-search="true" name="cid" style="width: 50%;">
                        <option value="0" hassubinfo="true">请选择分类</option>
                        {loop $class $index $vo}
                        <option value="{$vo['id']}" {if $vo['id']==$list['cid']}selected{/if}>{$vo['name']}</option>
                        {/loop}
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">头像（150*150）</label>
                <div class="col-sm-8">
                    {php echo tpl_form_field_image('simg',$list['simg']);}
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">职称</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control"  name="task" value="{$list['task']}">
                </div>
            </div>
            <div class="form-group">
                <label  class="col-sm-2 control-label">简介模式</label>
                <div class="col-sm-8">
                    <label class="radio inline" style="width: 60px;">
                        <input type="radio" class="ui-radio" name="content_type" id="content_type1" value="1" {if $list['content_type']==1}checked{/if}>多行文本
                    </label>
                    <label class="radio inline">
                        <input type="radio" class="ui-radio" name="content_type" id="content_type2" value="2" {if $list['content_type']==2}checked{/if}>编辑器
                    </label>
                </div>
            </div>
            <div class="form-group">
                <label  class="col-sm-2 control-label">个人简介</label>
                <div class="col-sm-8 content_type1">
                    <textarea rows="20" class="form-control"  name="short_info" id="short_info">{$list['short_info']}</textarea>
                </div>
                <div class="col-sm-10 content_type2">
                    {php echo tpl_ueditor('content2',$list['content2']);}
                </div>
            </div>
            <div class="form-group">
                <label  class="col-sm-2 control-label">负责课程</label>
                <div class="col-sm-8">
                    <textarea rows="20" class="form-control"  name="pclass" id="pclass">{$list['pclass']}</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">状态</label>
                <div class="col-sm-8">
                    {if $list['status']==1}
                    <input type="checkbox" checked class="js-switch" value="1" name="status">
                    {else}
                    <input type="checkbox" class="js-switch" name="status" value="1">
                    {/if}
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">排序</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control"  name="sort" value="{$list['sort']}">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <input type="button" name="submit" class="btn btn-default" value="提交">
                    <a class="btn btn-default" href="{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'])}">返回</a>
                    <input id="res" name="res" type="reset" style="display:none;" />
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    if($("#content_type1").is(":checked")){
        $(".content_type2").hide();
        $(".content_type1").show();
    }else if($("#content_type2").is(":checked")){
        $(".content_type1").hide();
        $(".content_type2").show();
    }
    require(["../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.js","../addons/{php echo $_GPC['m']}/resource/bootstrap-select/bootstrap-select.min.js"],function(){
        $('.selectpicker').selectpicker();
        $(function(){
            $("input[name='content_type']").change(function(){
                if($("#content_type1").is(":checked")){
                    $(".content_type2").hide();
                    $(".content_type1").show();
                }else if($("#content_type2").is(":checked")){
                    $(".content_type1").hide();
                    $(".content_type2").show();
                }
            });
            $("input[name='submit']").click(function(){
                var data=$(".form-horizontal").serialize();
                $.ajax({
                    type:"post",
                    url:"{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'],'op'=>'savemodel','version_id'=>$_GPC['version_id'])}",
                    data:data,
                    dataType:'json',
                    success:function(res){
                        if(res.status==1){
                            if($("input[name='id']").val()==""){
                                $("input[name='res']").click();
                                $("body").find(".img-responsive.img-thumbnail").attr("src","");
                                $(".selectpicker").selectpicker('refresh');
                            }
                            swal('操作成功!', '操作成功!', 'success');
                        }else{
                            swal('操作失败!', '操作失败!', 'error');
                        }
                    }
                })
            });
        })
    })
</script>
{template 'common/footer'}